package com.hanbang.maige.view.aboutme.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hanbang.maige.R;
import com.hanbang.maige.code.base.view.fragment.BaseMvpFragment;
import com.hanbang.maige.mode.javabean.base.UserData;
import com.hanbang.maige.pressenter.aboutme.AboutMePresenter;
import com.hanbang.maige.utils.bitmap.GlideOptions;
import com.hanbang.maige.utils.bitmap.GlideUtils;
import com.hanbang.maige.view.aboutme.IAboutMeBaseView;
import com.hanbang.maige.view.aboutme.activity.GeRenZiLiaoActivity;
import com.hanbang.maige.view.aboutme.activity.MyMessageActivity;
import com.hanbang.maige.view.aboutme.activity.MyXiangCeActivity;
import com.hanbang.maige.widget.ScaleImageView;

import butterknife.BindView;
import butterknife.OnClick;
import jp.wasabeef.glide.transformations.CropCircleTransformation;

import static com.hanbang.maige.code.MyApplication.myApp;
import static com.hanbang.maige.mode.javabean.base.UserData.userData;

/**
 * 作者　　: 李坤
 * 创建时间:2016/10/17　15:45
 * 邮箱　　：496546144@qq.com
 * <p>
 * 功能介绍：
 */

public class AboutMeBaseFragment extends BaseMvpFragment<IAboutMeBaseView.IAboutMeView, AboutMePresenter> implements IAboutMeBaseView.IAboutMeView {
    @BindView(R.id.gerenziliaoTv)
    TextView gerenziliaoTv;
    @BindView(R.id.touxiangBag)
    ScaleImageView touxiangBag;
    @BindView(R.id.headIv)
    ImageView headIv;
    @BindView(R.id.guanzhuTv)
    TextView guanzhuTv;
    @BindView(R.id.guanzhuLL)
    LinearLayout guanzhuLL;
    @BindView(R.id.fenshiTv)
    TextView fenshiTv;
    @BindView(R.id.fenshiLL)
    LinearLayout fenshiLL;
    @BindView(R.id.biaoqianTv)
    TextView biaoqianTv;
    @BindView(R.id.huodongLL)
    LinearLayout huodongLL;
    @BindView(R.id.xiangcheLL)
    LinearLayout xiangcheLL;
    @BindView(R.id.xiaoxiLL)
    LinearLayout xiaoxiLL;
    @BindView(R.id.guanyuMaige)
    TextView guanyuMaige;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public AboutMePresenter initPressenter() {
        return new AboutMePresenter();
    }

    @Override
    public int getContentView() {
        return R.layout.fragment_about_me;
    }

    @Override
    public void initView() {

    }

    @Override
    public void clearData() {

    }

    private void upStaticData() {
        if (UserData.getUserData() != null) {
            GlideUtils.show(headIv, userData.getHeadPhotoSma(), new GlideOptions.Builder()
                    .setPlaceholder1_1()
                    .addTransformation(new CropCircleTransformation(myApp))
                    .bulider());
            GlideUtils.show(touxiangBag, userData.getHeadPhotoMid(), new GlideOptions.Builder()
                    .bulider());
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        upStaticData();
    }

    @OnClick(R.id.gerenziliaoTv)
    public void onClick() {
        GeRenZiLiaoActivity.startUI(AboutMeBaseFragment.this.getActivity());
    }


    @OnClick({R.id.huodongLL, R.id.xiangcheLL, R.id.outLogin, R.id.xiaoxiLL, R.id.guanyuMaige, R.id.guanzhuLL, R.id.fenshiLL, R.id.biaoqianTv})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.huodongLL:
                break;
            case R.id.outLogin:
                if (UserData.getUserData() != null) {
                    UserData.userData.exit(getContext());
                }
                break;
            case R.id.xiangcheLL:
                MyXiangCeActivity.startUI(AboutMeBaseFragment.this.getActivity());
                break;
            case R.id.xiaoxiLL:
                MyMessageActivity.startUI(AboutMeBaseFragment.this.getActivity());
                break;
            case R.id.guanyuMaige:
                break;
            case R.id.guanzhuLL:
                break;
            case R.id.fenshiLL:
                break;
            case R.id.biaoqianTv:
                break;
        }
    }
}
